package com.atguigu.day01;

/**
 * 面试题
 *
 * @author sx
 * @date 2022-02-24 15:49
 */
public class Demo8 {
    public static void main(String[] args) {
        SuperClass s = new SubClass();
        System.out.println(s.getValue());
        System.out.println(s.getSum());
    }
}

abstract class SuperClass {
    private int i;

    public SuperClass() {
        i = 5;
    }

    public int getValue() {
        System.out.println("i==>" + i);
        return i;
    }

    public abstract int getSum();
}

class SubClass extends SuperClass {
    int j;

    public SubClass() {
        this(-3);
        System.out.println("j==>" + j);
    }

    public SubClass(int j) {
        System.out.println("j=====>" + j);
        this.j = j;
    }

    @Override
    public int getValue() {
        return j;
    }

    @Override
    public int getSum() {
        return super.getValue() + j;
    }
}
